package cn.edu.lzu.dao;

import cn.edu.lzu.entity.ExaminePackage;
import cn.edu.lzu.entity.Examiner;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @PackageName: cn.edu.lzu.dao
 * @InterfaceName: ExaminePackageMapper
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2019/12/10 15:06
 * @Version: 1.0
 */
@Mapper
public interface ExaminePackageMapper {
    @Select("select * from examine_package where is_deleted=0 and unit_id=#{unitId} limit #{startIndex}, #{pageSize}")
    List<ExaminePackage> selPageExaminePackageByUnitId(long unitId, int startIndex, int pageSize);

    @Select("select count(*) from examine_package where is_deleted=0 and unit_id=#{unitId} ")
    int selPackageTotalCountByUnitIdNotDeleted(long unitId);

    @Update("update examine_package set is_deleted=1 where examine_package_id = #{examinePackageId}")
    int updDeleteExaminePackageById(int examinePackageId);

    @Update("update examine_package set is_deleted=1 where examine_package_id in (${examinePackageIds})")
    int updBatchDeleteExaminePackagesByIds(String examinePackageIds);

    @Insert("insert into examine_package (examine_package_id, package_name, apply_sex, apply_range, price, note, unit_id, is_deleted) values (default, #{packageName}, #{applySex}, #{applyRange}, #{price}, #{note}, #{unitId}, 0 )")
    int insExaminePackage(ExaminePackage examinePackage);

    @Select("select * from examine_package where package_name=#{packageName} and is_deleted=0 and unit_id=#{unitId}")
    ExaminePackage selPackageByName(String packageName, long unitId);

    @Select("select * from examine_package where is_deleted=0 and apply_sex!=#{applySex} and unit_id=#{unitId}")
    List<ExaminePackage> selUnitPackageBySex(ExaminePackage examinePackage);

    @Select("select * from examine_package where examine_package_id=#{examinePackageId}")
    ExaminePackage selExaminePackageById(int examinePackageId);

    @Select("select * from examine_package where is_deleted=0 and unit_id=#{unitId}")
    List<ExaminePackage> selUnitAllPackages(Long unitId);
}
